home *** CD-ROM | disk | FTP | other *** search
/ SGI Developer Toolbox 6.1 / SGI Developer Toolbox 6.1 - Disc 4.iso / public / cdsend / db_get_TOC.c < prev    next >
C/C++ Source or Header  |  1994-08-01  |  627b  |  28 lines

  1. #include <string.h>
  2. #include <sys/types.h>
  3. #include <cdaudio.h>
  4.  
  5. #define    MAX_CATALOG    (99*3+6+1)
  6.  
  7. const char *
  8. db_get_TOC( CDPLAYER *cdplayer, CDSTATUS *status )
  9. {
  10. CDTRACKINFO    info;
  11. int        min, sec, i;
  12. char        buf[MAX_CATALOG], *bufp = buf, *tmp;
  13.  
  14.     if (status->state == CD_NODISC || status->state == CD_ERROR)
  15.     return (NULL);
  16.  
  17.     sprintf( bufp, "%02d", status->last - status->first + 1 );
  18.     bufp += 2;
  19.  
  20.     for (i = status->first; i <= status->last; i++) {
  21.     CDgettrackinfo( cdplayer, i, &info );
  22.     sprintf( bufp, "%02d%02d", info.total_min, info.total_sec );
  23.     bufp += 4;
  24.     }
  25.     *bufp++ = '\0';
  26.     return (strdup( buf ));
  27. }
  28.